/** 
* All Rights Reserved , Copyright (C) 2020 , 青岛鼎信通讯股份有限公司
* 
* BaseShareManageServiceAuto
* 共享管理
* 
* 修改纪录
* 2020-08-27 版本：1.0 donghang 创建。
* @version 版本：1.0
* @author 作者：donghang
* 创建日期：2020-08-27
*/

package com.topscomm.base.service.impl.auto;

import java.util.Map;

import javax.annotation.Resource;

import com.topscomm.base.BaseService;
import com.topscomm.base.dao.IBaseShareManageDao;
import com.topscomm.base.pojo.BaseShareManageEntity;
import com.topscomm.basic.IBasicDao;
import com.topscomm.tap.common.DatacodeCache;

public class BaseShareManageServiceAuto extends BaseService<BaseShareManageEntity, IBaseShareManageDao> {

	/**
	 * @author: donghang
	 * @date: 2020-08-27
	 * @param mapRow
	 * @description:设置字段显示值
	 * @modify:
	 */
	@Override
	public void setDispFields(Map<String, Object> mapRow, DatacodeCache datacodeCache) {
		String temp;
		if (mapRow.get("sharetype") != null) {
			temp = mapRow.get("sharetype").toString();
			mapRow.put("dispsharetype", datacodeCache.getValueDynamic("MeetShare", temp, "code", "name"));
		}
		if (mapRow.get("shareroleids") != null) {
			temp = mapRow.get("shareroleids").toString();
			String[] roleIDs = temp.split(",");
			StringBuilder roleNames = new StringBuilder();
			for (String roleID : roleIDs) {
				roleNames.append(datacodeCache.getValueDynamic("CboRole", roleID, "id", "name"));
				roleNames.append(",");
			}
			int length = roleNames.length();
			if (length > 0) {
				mapRow.put("dispsharerolenames", roleNames.substring(0, length - 1));
			}
		}
		if (mapRow.get("shareteamids") != null) {
			temp = mapRow.get("shareteamids").toString();
			String[] teamIDs = temp.split(",");
			StringBuilder teamNames = new StringBuilder();
			for (String teamID : teamIDs) {
				teamNames.append(datacodeCache.getValueDynamic("BaseTeamInfo", teamID, "id", "name"));
				teamNames.append(",");
			}
			int length = teamNames.length();
			if (length > 0) {
				mapRow.put("dispshareteamnames", teamNames.substring(0, length - 1));
			}
		}
		if (mapRow.get("enabled") != null) {
			temp = mapRow.get("enabled").toString();
			mapRow.put("dispenabled", datacodeCache.getValueDynamic("CboYesNo", temp, "code", "name"));
		}
	}

	@Override
	@Resource(name = "baseShareManageDao")
	public void setDao(IBasicDao<BaseShareManageEntity> dao) {
		super.setDao(dao);
	}
}
